% Function implementing equality constraints
function y = cloth_eqconstr_3(array,Restlength,D,m,g)

% Convert array to 3d tensor
tensor = array2tensor(array);
N=length(tensor(:,1,1));
hulpmatrix = zeros(4,3);

% Every point has a penalty for the distance from the desired coordinates
Aeq=zeros(3,N^2);
Aeq(1,N^2)=1; 
Aeq(2,N)=1;
Aeq(3,N^2-N+1)=1;
Aeq=kron(Aeq,eye(3));
% Desired positions
beq=[N/2 N/2 1 -N/2 N/2 1 N/2 -N/2 1];
y = Aeq*array-beq';
